<template>
	<div class="allcontainer" v-loading="loading">
		<div class="h2">学生组织申请</div>
		<div class="bg-white">
			<div class="table">
				<el-table stripe ref="singleTable" :data="data" highlight-current-row style="width: 100%">
					<el-table-column type="index" label="序号" width="60" fixed="left" align="center"></el-table-column>
					<el-table-column prop="ClubName" label="名称" min-width="100" fixed="left"></el-table-column>
					<!-- <el-table-column prop="UserNo" label="学号" min-width="120"></el-table-column> -->
					<el-table-column prop="IsAgree" label="状态" min-width="120" align="center">
						<template slot-scope="scope">
							<a-tag color="orange" v-if="scope.row.IsAgree==null"> 待审核 </a-tag>
							<a-tag color="green" v-if="scope.row.IsAgree==true"> 审核通过 </a-tag>
							<a-tag color="red" v-if="scope.row.IsAgree==false"> 审核未通过 </a-tag>
						</template>
					</el-table-column>
					<el-table-column prop="Reason" label="申请理由" min-width="100">
					</el-table-column>
					<el-table-column prop="AddTime" label="申请时间" min-width="100" align="center"></el-table-column>
					<el-table-column prop="ReplyComment" label="审核内容" min-width="100">
						<template slot-scope="scope">
							<div>{{ scope.row.ReplyComment }}</div>
							<!-- <div>{{ scope.row.ReplyTime }}</div> -->
						</template>
					</el-table-column>
					<el-table-column prop="IsEnable" label="操作" width="90" fixed="right">
						<template slot-scope="scope">
							<div class="user-btn">
								<span class="detail" @click="detail(scope.row)">详情</span>
							</div>
						</template>
					</el-table-column>
				</el-table>
				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
					:current-page="pagination.currentPage" :page-sizes="pagination.pageSizeOptions"
					:page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper"
					:total="pagination.total"></el-pagination>
			</div>
		</div>
		<detail :time="time" :text="text" v-show="showModal" @closeFun="closeFun(1)"></detail>
	</div>
</template>

<script>
	import Func from '@/utils/func';
	import Cache from '@/utils/cache'
	import {
		UserCenterDoGetApplyClubList,
		DeleteClub
	} from '@/api/follow';
	import detail from './userApplyClubRecordDeatil.vue'
	const data = [];
	export default {
		components: {
			detail
		},
		data() {
			return {
				data,
				form: this.$form.createForm(this, {
					name: 'advanced_search'
				}),
				pagination: {
					currentPage: 1,
					pageSize: this.global.pageSize,
					pageSizeOptions: this.global.pageSizeOptions, // 每页中显示的数据
					showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
				},
				addIf: false,
				text: {},
				visible: false,
				confirmLoading: false,
				itemId: '',
				departmentList: [],
				worklist: [],
				loading: false,
				values: {},
				pages: {
					pageIndex: 1,
					pageSize: 20
				},
				tableHeight: parseFloat(window.innerHeight - 160),
				TypeIDList: [],
				DepartCodeList: [],
				ProjectIDList: [],
				ishaveid: true,
				selectList: {},
				showModal: false,
				UserInfo: Cache.get('myInfo'),
				ChairmanNo: this.$route.query.ChairmanNo,
				linktype: 1,
				ClubID: this.$route.query.ID,
				visible: false,
				deletelist: {},
				time: ''
			};
		},
		computed: {},
		created() {
			this.getList();
			// this.getOtherList()
		},
		mounted() {},
		methods: {
			// setadmin(text) {
			// 	let data={}
			// 	data.
			// 	let res = await DoAddUserClubMember(data)
			// },
			canceladmin(text) {
				let that = this
				this.$confirm({
					title: '提示',
					content: `您确定取消该用户的管理员权限吗？`,
					okText: '确认',
					cancelText: '取消',
					async onOk() {
						let data = {}
						data.userNo = text.UserNo
						data.clubID = that.ClubID
						let res = await DoDeleteUserClubAdmin(data);
						if (res.data.code == 0) {
							that.getList()
							that.$message.success(res.data.msg)
						} else {
							that.$message.error(res.data.msg)
						}
					}
				})
			},
			handleCancel(e) {
				this.visible = false
				this.getList()
			},
			deletemember(text) {
				// this.visible = true
				// this.deletelist = text
				let that = this
				this.$confirm({
					title: '提示',
					content: `您确定删除该申请吗？`,
					okText: '确认',
					cancelText: '取消',
					async onOk() {
						let data = {}
						data.id = text.ID
						let res = await DeleteClub(data);
						if (res.data.code == 0) {
							that.getList()
							that.$message.success(res.data.msg)
						} else {
							that.$message.error(res.data.msg)
						}
					}
				})
			},
			detail(text) {
				this.text = {
					...text,
					time: new Date()
				}
				this.showModal = true
			},
			handleChange(val) {
				this.currentRow = val;
				if (val.ID) {
					this.ishaveid = false
					this.selectList = val
				} else {
					this.ishaveid = true
				}
			},
			handleSearch(e) {
				e.preventDefault();
				this.form.validateFields((error, values) => {
					this.pagination.currentPage = 1;
					this.values = values;
					this.getList();
				});
			},
			handleReset() {
				this.form.resetFields();
				this.values = {};
				this.getList();
			},
			handleSizeChange(val) {
				this.pagination.pageSize = val;
				this.getList();
			},
			handleCurrentChange(val) {
				this.pagination.currentPage = val;
				this.getList();
			},
			async getList() {
				this.loading = true;
				let data = {};
				if (this.values) {
					data = this.values;
				}
				data.clubID = this.$route.query.ID
				data.pageIndex = this.pagination.currentPage;
				data.pageSize = this.pagination.pageSize;
				let res = await UserCenterDoGetApplyClubList(data);
				this.loading = false;
				this.data = res.data.data;
				const pagination = {
					...this.pagination
				};
				pagination.total = res.data.pageInfo.TotalItemCount;
				this.pagination = pagination;
			},
			addList() {
				this.text = {};
				this.addIf = !this.addIf;
			},
			modifyList(text) {
				text = Object.assign(text, {
					time: new Date()
				});
				this.addIf = !this.addIf;
				this.text = text;
			},
			closeFun(index) {
				this.showModal = false
				this.getList()
			},
		}
	};
</script>
